package com.jcl.elasticsearch.resume.logic;

import com.jcl.core.utils.CollectionUtils;
import com.jcl.elasticsearch.mapper.SearchResumeJobIntentionMapper;
import com.jcl.elasticsearch.resume.model.SearchResumeJobIntention;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName SearchResumeJobIntentionLogic
 * @Description TODO
 * @Author yyliu
 * @Date 2018/11/17 11:51
 * @Version 1.0
 **/
@Component
public class SearchResumeJobIntentionLogic implements SearchResumeJobIntentionMapper {

    @Autowired
    SearchResumeJobIntentionMapper searchResumeJobIntentionMapper;

    public Map<Integer, SearchResumeJobIntention> findEntityMapByResumeIds(List<Integer> resumeIds){
        Map<Integer, SearchResumeJobIntention> dataMap = new HashMap<>();
        List<SearchResumeJobIntention> list = searchResumeJobIntentionMapper.findListByResumeIds(resumeIds);
        if(CollectionUtils.isNotEmpty(list)){
           for(SearchResumeJobIntention entity: list){
               dataMap.put(entity.getResumeId(), entity);
           }
        }

        return dataMap;
    }

    @Override
    public List<SearchResumeJobIntention> findListByResumeIds(List<Integer> resumeIds) {
        return searchResumeJobIntentionMapper.findListByResumeIds(resumeIds);
    }

    @Override
    public Map<String, Object> findOneMap(Integer resumeId) {
        return searchResumeJobIntentionMapper.findOneMap(resumeId);
    }

    @Override
    public SearchResumeJobIntention findOne(Integer resumeId) {
        return searchResumeJobIntentionMapper.findOne(resumeId);
    }

    @Override
    public int add(SearchResumeJobIntention entity) {
        return searchResumeJobIntentionMapper.add(entity);
    }

    @Override
    public int batchDeleteByResumeIds(List<Integer> resumeIds) {
        return searchResumeJobIntentionMapper.batchDeleteByResumeIds(resumeIds);
    }
}
